﻿// ***********************************************************************
// Assembly         : MVC4Portal
// Author           : LJO+01 (Laurent Jordi)
// Created          : 06-05-2013
// Last Modified By : LJO+01 (Laurent Jordi)
// Last Modified On : 06-05-2013
// ***********************************************************************
// <copyright file="MyProfileController.cs" company="Copyright © Innovacall 2011">
//     Copyright (c) Copyright © Innovacall 2011. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Transactions;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using EmitMapper;
using InnovaApp.Layers.CommonLayer;
using InnovaApp.Layers.DataLayer;
using InnovaApp.Layers.DomainLayer;
using InnovaApp.Layers.ResourcesLayer.Properties;
using InnovaApp.Layers.SecurityLayer.Models.MetaModels;
using InnovaApp.Portals.MVC4Portal.Models.JSonModels;
using InnovaApp.Portals.MVC4Portal.Models.MetaModels.ContactManagement;
using InnovaApp.Portals.MVC4Portal.Models.ViewModels;
using InnovaApp.Portals.MVC4Portal.Models.ViewModels.LayoutViewModels;
using INNOVACALL.Framework.Common;
using INNOVACALL.Framework.Common.Extensions;
using INNOVACALL.Framework.Common.InnovacallExceptions;
using INNOVACALL.Framework.Common.MVCHelpers;
using INNOVACALL.Framework.Common.MVCHelpers.Localization;
using System.Drawing;
using System.Drawing.Imaging;
using InnovaApp.Portals.MVC4Portal.Filters;
using INNOVACALL.Framework.Common.Models;

namespace InnovaApp.Portals.MVC4Portal.Controllers.ViewControllers
{
    /// <summary>
    /// Class MyProfileController
    /// </summary>
    public partial class LookupsController : _ViewControllers_Base<Lookups_ViewModel>
    {
        /// <summary>
        /// Initializes data that might not be available when the constructor is called.
        /// </summary>
        /// <param name="requestContext">The HTTP context and route data.</param>
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.eMethodBase = "InnovaApp.Portals.InnovaAppFrontOfficePortal.Controllers.LookupsController";
            base.Initialize(requestContext);
        }


        /// <summary>
        /// Gets a lookup element
        /// </summary>
        /// <param name="language">The language.</param>
        /// <param name="ajaxModel">The ajax model.</param>
        /// <returns>JsonResult.</returns>
        /// <exception cref="System.NotImplementedException">Generic Lookup not available for this object</exception>
        [HttpPost, Authorize, CacheManager(enCacheMode.NoCache)]
        public JsonResult Get(string language, LookupDetailFeed_JSonModel ajaxModel)
        {
            string eMethod = eMethodBase + "Get[Post]";
            string scriptToExecute = string.Empty;
            object eParameters = new { language = language, ajaxModel = ajaxModel };
            INNOVACALL.Framework.Common.MVCHelpers.Localization.CommonLocalization.SetCurrentThreadLanguage(language);
            JsonResult toReturn;
            switch (ajaxModel.ItemType)
            {
                case "Competency":
                    toReturn = GetCompetency(ajaxModel);
                    break;
                case "TelecomType":
                    toReturn = GetTelecomType(ajaxModel);
                    break;
                default:
                    throw new NotImplementedException("Generic Lookup not available for this object");
            }
            return toReturn;
        }

        /// <summary>
        /// Deletes a lookup element
        /// </summary>
        /// <param name="language">The language.</param>
        /// <param name="ajaxModel">The ajax model.</param>
        /// <returns>JsonResult.</returns>
        /// <exception cref="System.NotImplementedException">Generic Lookup not available for this object</exception>
        [HttpPost, Authorize, CacheManager(enCacheMode.NoCache)]
        public JsonResult Delete(string language, LookupDetailFeed_JSonModel ajaxModel)
        {
            string eMethod = eMethodBase + "Get[Post]";
            string scriptToExecute = string.Empty;
            object eParameters = new { language = language, ajaxModel = ajaxModel };
            INNOVACALL.Framework.Common.MVCHelpers.Localization.CommonLocalization.SetCurrentThreadLanguage(language);
            JsonResult toReturn;
            switch (ajaxModel.ItemType)
            {
                case "Competency":
                    toReturn = DeleteCompetency(ajaxModel);
                    break;
                case "TelecomType":
                    toReturn = DeleteTelecomType(ajaxModel);
                    break;
                default:
                    throw new NotImplementedException("Generic Lookup not available for this object");
            }
            return toReturn;
        }
    }
}
